﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="XuatKho.ascx.cs" Inherits="XuatKho" %>
<center>
    <asp:Panel ID="pnGridMaster" runat="server" Width="700px">
        <span class="BigLabel1">HÓA ĐƠN XUẤT KHO</span>
        <asp:DataGrid ID="masterGrid" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            OnItemCommand="masterGrid_ItemCommand" OnItemDataBound="masterGrid_ItemDataBound"
            OnPageIndexChanged="masterGrid_PageIndexChanged" PageSize="15" Width="100%" DataSourceID="dsMaster">
            <PagerStyle Mode="NumericPages" />
            <AlternatingItemStyle CssClass="DarkRow" />
            <ItemStyle CssClass="LightRow" />
            <Columns>
                <asp:BoundColumn HeaderText="M&#227; H&#243;a đơn" DataField="MaHoaDon"></asp:BoundColumn>
                <asp:BoundColumn HeaderText="Kho xuất" DataField="KhoXuat"></asp:BoundColumn>
                <asp:BoundColumn HeaderText="Nội Dung" DataField="NoiDung"></asp:BoundColumn>
                <asp:BoundColumn HeaderText="Người xuất" DataField="NguoiXuat"></asp:BoundColumn>
                <asp:TemplateColumn>
                    <ItemTemplate>
                        <asp:Button ID="cmdEdit" runat="server" CausesValidation="False" CommandName="cmdEdit"
                            Text="Sửa" Width="40" />
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateColumn>
                <asp:TemplateColumn>
                    <ItemTemplate>
                        <asp:Button CausesValidation="False" ID="cmdDelete" runat="server" Text="Xóa" Width="40"
                            CommandName="cmdDelete"></asp:Button>
                    </ItemTemplate>
                </asp:TemplateColumn>
            </Columns>
            <HeaderStyle CssClass="HeaderRow" Font-Bold="True" />
        </asp:DataGrid>
        <asp:SqlDataSource ID="dsMaster" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
            ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" SelectCommand="select * from HoaDon_Master order by mahoadon desc">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="ds" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
            ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>"></asp:SqlDataSource>
        <asp:Button ID="cmdAddNewMaster" runat="server" Text="Thêm mới" OnClick="cmdAddNewMaster_Click" />
    </asp:Panel>
    <asp:Panel ID="pnEditMaster" runat="server" Width="700px" HorizontalAlign="Center">
        <table width="100%" class="TableStyle" cellpadding="0" cellspacing="1">
            <tr>
                <td colspan="4" align="center">
                    <span class="BigLabel2"></span>HÓA ĐƠN XUẤT KHO<br />
                    <asp:Label runat="server" ID="lblEditMode" ForeColor="Blue"></asp:Label>
                    <asp:Label runat="server" ID="lblMaHoaDon" Text=""></asp:Label>
                    
                    </td>
            </tr>
            <tr class="TrStyle">
                <td colspan="4" align="center">
                    Loại giao dịch:
                    <asp:DropDownList runat="server" ID="cboLoaiGiaoDich">
                        <asp:ListItem Value="2" Text="Xuất phân phối"></asp:ListItem>
                        <asp:ListItem Value="3" Text="Xuất điều chuyển"></asp:ListItem>
                        <asp:ListItem Value="4" Text="Xuất cấp trên"></asp:ListItem>
                        <asp:ListItem Value="5" Text="Xuất dùng"></asp:ListItem>
                        <asp:ListItem Value="6" Text="Xuất hủy"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr class="TrStyle">
                <td class="TdStyle" width="25%" style="text-align: left; height: 24px;">
                    Mã lô</td>
                <td class="TdStyle" width="25%" style="text-align: left; height: 24px;">
                    <asp:TextBox ID="txtMaLo" runat="server"></asp:TextBox></td>
                <td class="TdStyle" width="25%" style="text-align: left; height: 24px;">
                    Năm</td>
                <td class="TdStyle" width="25%" style="text-align: left; height: 24px;">
                    <asp:TextBox ID="txtNam" runat="server"></asp:TextBox></td>
            </tr>
            <tr class="TrStyle">
                <td class="TdStyle" width="25%" style="text-align: left">
                    Ngày xuất</td>
                <td class="TdStyle" width="25%" style="text-align: left">
                    <input onkeypress="" type="text" runat="server" id="txtNgayXuat" class="TextBoxGachDuoi"
                        onfocus="showCalendarControl(this);" />
                </td>
                <td class="TdStyle" width="25%" style="text-align: left">
                    Ngày xuất thực tế</td>
                <td class="TdStyle" width="25%" style="text-align: left">
                    <input onkeypress="" type="text" runat="server" id="txtNgayXuatThucTe" class="TextBoxGachDuoi"
                        onfocus="showCalendarControl(this);" />
                </td>
            </tr>
            <tr class="TrStyle">
                <td class="TdStyle" width="25%" style="height: 26px; text-align: left;">
                    Ngày nhận</td>
                <td class="TdStyle" width="25%" style="height: 26px; text-align: left;">
                    <input onkeypress="" type="text" runat="server" id="txtNgayNhan" class="TextBoxGachDuoi"
                        onfocus="showCalendarControl(this);" />
                </td>
                <td class="TdStyle" width="25%" style="height: 26px; text-align: left;">
                    Ngày nhận thực tế</td>
                <td class="TdStyle" style="height: 26px; text-align: left;">
                    <input onkeypress="" type="text" runat="server" id="txtNgayNhanThucTe" class="TextBoxGachDuoi"
                        onfocus="showCalendarControl(this);" />
                </td>
            </tr>
            <tr class="TrStyle">
                <td class="TdStyle" width="25%" style="height: 26px; text-align: left;">
                    Kho nhận</td>
                <td class="TdStyle" width="25%" style="height: 26px; text-align: left;">
                    <asp:DropDownList runat="server" ID="cboKhoNhan" Width="154px" DataSourceID="dsKhoNhan"
                        DataTextField="TenKho" DataValueField="MaKho" AutoPostBack="True" OnSelectedIndexChanged="cboKhoNhan_SelectedIndexChanged">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="dsKhoNhan" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
                        ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" SelectCommand="select MaKho, MaKho+ ' - '+isnull(TenKho,'') as TenKho from MaKho">
                    </asp:SqlDataSource>
                </td>
                <td class="TdStyle" width="25%" style="height: 26px; text-align: left;">
                    Người nhận</td>
                <td class="TdStyle" style="height: 26px; text-align: left;">
                    <asp:DropDownList runat="server" ID="cboNguoiNhan" Width="154px" DataSourceID="dsNguoiNhan"
                        DataTextField="User_FullName" DataValueField="UserNameCMT">
                    </asp:DropDownList><asp:SqlDataSource ID="dsNguoiNhan" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
                        ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" SelectCommand="select user_Name+':_:'+ isnull(CMT,'') as UserNameCMT, User_FullName from Users where makho=@MaKho">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="cboKhoNhan" Name="MaKho" PropertyName="SelectedValue" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr class="TrStyle">
                <td class="TdStyle" style="height: 51px; text-align: left" width="25%">
                    Nội dung</td>
                <td class="TdStyle" colspan="3" style="height: 51px; text-align: left">
                    <asp:TextBox ID="txtNoiDung" TextMode="MultiLine" runat="server" Height="49px" Width="99%"></asp:TextBox></td>
            </tr>
            <tr class="TrStyle">
                <td colspan="4" align="center">
                    <asp:Label ID="lblKetQuaInsert" runat="server" ForeColor="Blue"></asp:Label>
                    <asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label></td>
            </tr>
            <tr class="TrStyle">
                <td align="center" colspan="4">
                    <asp:Button runat="server" ID="cmdSaveMaster" Text="Lưu hóa đơn" OnClick="cmdSaveMaster_Click" />
                    <asp:Button runat="server" ID="cmdCancelSaveMaster" Text="Hủy bỏ" OnClick="cmdCancelSaveMaster_Click" />
                    <asp:Button runat="server" ID="cmdExitEditMaster" Text="Thoát" OnClick="cmdExitEditMaster_Click" />
                </td>
            </tr>
            <tr class="TrStyle">
                <td width="25%" style="height: 26px; text-align: left;">
                </td>
                <td width="25%" style="height: 26px; text-align: left;">
                </td>
                <td width="25%" style="height: 26px; text-align: left;">
                </td>
                <td style="height: 26px; text-align: left;">
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnGridDetail" runat="server" Width="700px">
        <span class="BigLabel2">CHI TIẾT HÓA ĐƠN</span>
        <asp:DataGrid ID="detailGrid" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            OnItemCommand="detailGrid_ItemCommand" OnItemDataBound="detailGrid_ItemDataBound"
            OnPageIndexChanged="detailGrid_PageIndexChanged" Width="100%" DataSourceID="dsDetail">
            <PagerStyle Mode="NumericPages" />
            <AlternatingItemStyle CssClass="DarkRow" />
            <ItemStyle CssClass="LightRow" />
            <Columns>
                <asp:BoundColumn HeaderText="id" DataField="id"></asp:BoundColumn>
                <asp:BoundColumn HeaderText="seri" DataField="seri"></asp:BoundColumn>
                <asp:BoundColumn HeaderText="ChiSoDau" DataField="ChiSoDau"></asp:BoundColumn>
                <asp:BoundColumn HeaderText="ChiSoCuoi" DataField="ChiSoCuoi"></asp:BoundColumn>
                <asp:BoundColumn HeaderText="M&#227; H&#243;a đơn" DataField="MaHoaDon"></asp:BoundColumn>
                <asp:BoundColumn HeaderText="Kho xuất" DataField="KhoXuat"></asp:BoundColumn>
                <asp:BoundColumn HeaderText="Nội Dung" DataField="GhiChu"></asp:BoundColumn>
                <asp:BoundColumn HeaderText="Người xuất" DataField="Ngay"></asp:BoundColumn>
                <asp:TemplateColumn>
                    <ItemTemplate>
                        <asp:Button ID="cmdEdit" runat="server" CausesValidation="False" CommandName="cmdEdit"
                            Text="Sửa" Width="40" />
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateColumn>
                <asp:TemplateColumn>
                    <ItemTemplate>
                        <asp:Button CausesValidation="False" ID="cmdDelete" runat="server" Text="Xóa" Width="40"
                            CommandName="cmdDelete"></asp:Button>
                    </ItemTemplate>
                </asp:TemplateColumn>
            </Columns>
            <HeaderStyle CssClass="HeaderRow" Font-Bold="True" />
        </asp:DataGrid>
        <asp:Button runat="server" ID="cmdAddDetail" Text="Thêm chi tiết" OnClick="cmdAddDetail_Click" />
        <asp:SqlDataSource ID="dsDetail" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
            ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" SelectCommand="select * from HoaDon_Detail where mahoadon= @MaHoaDon">
            <SelectParameters>
                <asp:ControlParameter ControlID="lblMaHoaDon" Name="MaHoaDon" PropertyName="Text" />
            </SelectParameters>
        </asp:SqlDataSource>
    </asp:Panel>
    <asp:Panel ID="pnEditDetail" runat="server" Width="700px">
        <table width="100%" class="TableStyle" cellpadding="0" cellspacing="1">
            <tr>
                <td colspan="4" align="center" class="BigLabel2">
                    THÔNG TIN CHUNG
                </td>
            </tr>
            <tr class="TrStyle">
                <td colspan="4" align="center">
                    Mã hóa đơn chi tiết:
                    <asp:Label runat="server" ID="lblMaChiTiet" ForeColor="Blue"></asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="4" align="center">
                    <span class="BigLabel2" id="chiTietHoaDon">CHI TIẾT HÓA ĐƠN</span>
                </td>
            </tr>
            <tr class="TrStyle">
                <td class="TdStyle" width="25%" style="text-align: left">
                    Mã ấn chỉ</td>
                <td class="TdStyle" width="25%" style="text-align: left">
                    <asp:DropDownList runat="server" ID="cboMaAnChi" Width="218px" DataSourceID="dsMaAnChi"
                        DataTextField="TenAnChi" DataValueField="Ma" AutoPostBack="True" OnSelectedIndexChanged="cboMaAnChi_SelectedIndexChanged">
                    </asp:DropDownList><asp:SqlDataSource ID="dsMaAnChi" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
                        ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" SelectCommand="select ma,tenanchi from maanchi">
                    </asp:SqlDataSource>
                </td>
                <td class="TdStyle" width="25%" style="text-align: left">
                    Seri</td>
                <td class="TdStyle" width="25%" style="text-align: left">
                    <asp:DropDownList runat="server" ID="cboSeri" Width="194px" DataSourceID="dsSeri"
                        DataTextField="Seri" DataValueField="Seri">
                    </asp:DropDownList><asp:SqlDataSource ID="dsSeri" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
                        ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" SelectCommand="Select Seri from seriAC where ma=@ma">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="cboMaAnChi" Name="ma" PropertyName="SelectedValue" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr class="TrStyle">
                <td width="25%" style="height: 26px; text-align: left;">
                    Chỉ số đầu</td>
                <td width="25%" style="height: 26px; text-align: left;">
                    <asp:TextBox ID="txtChiSoDau" runat="server"></asp:TextBox></td>
                <td width="25%" style="height: 26px; text-align: left;">
                    Chỉ số cuối</td>
                <td style="height: 26px; text-align: left;">
                    <asp:TextBox ID="txtChiSoCuoi" runat="server"></asp:TextBox></td>
            </tr>
            <tr class="TrStyle">
                <td style="height: 26px; text-align: left" width="25%">
                    Loại ấn chỉ</td>
                <td style="height: 26px; text-align: left" width="25%">
                    <asp:TextBox ID="txtLoaiAnChi" runat="server"></asp:TextBox>
                    
                </td>
                <td style="height: 26px; text-align: left" width="25%">
                    Đợt phát hành</td>
                <td style="height: 26px; text-align: left">
                    <asp:TextBox ID="txtDotPhatHanh" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class="TrStyle">
                <td style="height: 26px; text-align: left" width="25%">
                    Tính chất ấn chỉ</td>
                <td style="height: 26px; text-align: left" width="25%">
                    <asp:TextBox ID="txtTinhChatAnChi" runat="server"></asp:TextBox>
                </td>
                <td style="height: 26px; text-align: left" width="25%">
                    Trạng thái AC</td>
                <td style="height: 26px; text-align: left">
                    <asp:TextBox ID="txtTrangThaiAC" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class="TrStyle">
                <td style="height: 26px; text-align: left" width="25%">
                    Đơn giá</td>
                <td style="height: 26px; text-align: left" width="25%">
                    <asp:TextBox ID="txtDonGia" runat="server"></asp:TextBox></td>
                <td style="height: 26px; text-align: left" width="25%">
                </td>
                <td style="height: 26px; text-align: left">
                </td>
            </tr>
            <tr class="TrStyle">
                <td style="height: 34px; text-align: left" width="25%">
                    Ghi chú</td>
                <td style="height: 34px; text-align: left" colspan="3">
                    <asp:TextBox ID="txtGhiChu" runat="server" TextMode="MultiLine" Width="99%" Height="100px"></asp:TextBox></td>
            </tr>
            <tr class="TrStyle">
                <td colspan="4" style="height: 26px; text-align: left">
                </td>
            </tr>
            <tr class="TrStyle">
                <td colspan="4" style="height: 26px; text-align: center">
                    <asp:Label ID="lblErrorChiTiet" runat="server" ForeColor="Red"></asp:Label></td>
            </tr>
            <tr class="TrStyle">
                <td colspan="4" style="height: 26px; text-align: center">
                    <asp:Button ID="cmdCapNhatDetail" runat="server" OnClick="cmdCapNhatDetail_Click"
                        Text="Cập nhật" />
                    <asp:Button ID="cmdHuyBoDetail" runat="server" Text="Hủy bỏ" OnClick="cmdHuyBoDetail_Click" /></td>
            </tr>
            <tr class="TrStyle">
                <td style="height: 26px; text-align: left" width="25%">
                </td>
                <td style="height: 26px; text-align: left" width="25%">
                </td>
                <td style="height: 26px; text-align: left" width="25%">
                </td>
                <td style="height: 26px; text-align: left">
                </td>
            </tr>
        </table>
    </asp:Panel>
</center>
